package com.hgt.springcloud.controller;

import com.hgt.springcloud.common.CommonResult;
import com.hgt.springcloud.entity.Payment;
import com.hgt.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: huanggaotao
 * @Description:
 * @Date: Created in 17:34 2021/6/21
 * @Modified By:
 */
@RestController
@Slf4j
public class OrderFeignController {

    @Autowired
    private PaymentFeignService paymentFeignService;

    @GetMapping("/consumer/payment/get/{id}")
    public CommonResult<Payment>  getPaymentById(@PathVariable("id") Long id){
        return paymentFeignService.getById(id);
    }

    @GetMapping("/test/timeout")
    public String paymentFeignTimeout(){
        //Openfeign底层是Ribbon，客户端一般默认等待1秒钟   ，服务提供者 故意让线程睡眠3秒钟
        return paymentFeignService.paymentFeignTimeout();
    }
}
